//
//  TTVLogService.m
//  TouchTV
//
//  Created by Wyman on 2017/9/1.
//  Copyright © 2017年 TouchTV. All rights reserved.
//

#import "TTVLogger.h"
//#import <Bugtags/Bugtags.h>
//#import "SQLogToolManager.h"
//控制台级别
static TTVLogLevel TTVTrackingConsoleLogLevel = TTVLogLevelVerbose;
//日志上传级别
static TTVLogLevel TTVTrackingUploadLogLevel  = TTVLogLevelWarn;

@implementation TTVLogger

+ (void)logLevel:(TTVLogLevel)level format:(NSString *)format, ... {
    if (format) {
        va_list args;
        va_start(args, format);
        NSString *message = [[NSString alloc] initWithFormat:format arguments:args];
        va_end(args);
        message = [TTVLogger formatLogMessage:message level:level];
        
#ifdef DEBUG
        if (level <= TTVTrackingConsoleLogLevel) {
//            NSLog(@"%@", message);
            NSLog(@"%@", message);
        }
#else

#endif
        //log其他处理  BTGLog不输出控制台
        if (level <= TTVTrackingUploadLogLevel) {
            ///Bugtags上传
//            BTGLog(@"%@", message);
        }
    }
}


+ (NSString *)formatLogMessage:(NSString *)logMessage level:(TTVLogLevel)level {
    NSString *logLevel = nil;
    switch (level)
    {
        case TTVLogLevelError:
            logLevel = @"[ERROR] > ";
            break;
        case TTVLogLevelWarn:
            logLevel = @"[WARN]  > ";
            break;
        case TTVLogLevelInfo:
            logLevel = @"[INFO]  > ";
            break;
        case TTVLogLevelDebug:
            logLevel = @"[DEBUG] > ";
            break;
        default:
            logLevel = @"[VBOSE] > ";
            break;
    }
    
    NSString *formatStr = [NSString stringWithFormat:@"%@%@", logLevel, logMessage];
    return formatStr;
}



// 记录日志
- (void)logLevel:(TTVLogLevel)level message:(NSString *)message
{
    if (message.length > 0)
    {
        switch (level)
        {
            case TTVLogLevelError:
                break;
                
            case TTVLogLevelWarn:
                break;
                
            case TTVLogLevelInfo:
                break;
                
            case TTVLogLevelDebug:
                break;
                
            default:
                break;
        }
    }
}

@end



